home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0012_Force Different Video Modes.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  5.5 KB  |  222 lines

  1. {
  2. VMode
  3. -----
  4.  
  5. Allows you to select your own mode to work in, could be very handy
  6. if you can access the 132 x 25, 50 modes etc that SVGA supports.
  7.  
  8. Just imagine using DIR and seeing a whole directory on one page!
  9.  
  10.  
  11. Usage:
  12.  
  13. VMODE <video mode>
  14.  
  15. Where video mode is a number in the range of 0 to 127.
  16.  
  17. }
  18.  
  19. Procedure Usage;
  20. Begin
  21.      Writeln;
  22.      Writeln('VMODE, (C) 1995 Scott Tunstall.');
  23.      Writeln;
  24.      Writeln('Usage :');
  25.      Writeln;
  26.      Writeln('VMODE [FORCE] <Video Mode required>');
  27.      Writeln;
  28.      Writeln('Where Video Mode can be one of the following :');
  29.      Writeln('      1 :  80 x 25');
  30.      Writeln('      2 : 132 x 25 (8 x 16 character size)');
  31.      Writeln('      3 : 132 x 43 (8 x 8 character size)');
  32.      Writeln('      4 : 132 x 25 (8 x 14 character size)');
  33.      Writeln;
  34.      Writeln('If your favourite video mode is not here you may force');
  35.      Writeln('it by using FORCE as the first parameter then the video');
  36.      Writeln('mode number as the second. (A list of all video mode');
  37.      Writeln('numbers should have come with your graphics card).');
  38.      Writeln;
  39.      Writeln('For example, to force graphics mode 93 which is the');
  40.      Writeln('1024 x 768 x 16 colour mode, you would type :');
  41.      Writeln;
  42.      Writeln('VMODE FORCE 93');
  43.      Writeln;
  44. End;
  45.  
  46.  
  47. {
  48. I'm sorry for including the expletive, but if you have problems with
  49. using this program then really you must be really stupid.
  50. }
  51.  
  52. Procedure YouArecluckingStupid;
  53. Begin
  54.      Writeln;
  55.      Writeln('Incorrect number of parameters ! Only 2 MAXIMUM allowed.');
  56.      Writeln;
  57. End;
  58.  
  59.  
  60.  
  61. {
  62. This procedure is called if their are two parameters and the
  63. first parameter is not FORCE.. This routine has to be here because
  64. I'll probably add more command line parameters as time goes on.
  65. }
  66.  
  67. Procedure ErrorInFirstParameter;
  68. Begin
  69.      Writeln;
  70.      Writeln('Error in the first parameter .. FORCE expected !');
  71.      Writeln;
  72. End;
  73.  
  74.  
  75.  
  76. {
  77. Set the desired video mode.
  78.  
  79. ModeWantedAsString is the string representation of the desired mode,
  80. for example if you wanted mode 93 you pass in '93'. Easy eh? This
  81. is here so that if I change the function of the parameters later
  82. it'll still be easy to interface (?!!)
  83.  
  84. Oh, damn. Why do I bother ?
  85. }
  86.  
  87. Procedure GoIntoVideoMode(ModeWantedAsString:String);
  88. Var ModeNumber,
  89.     ErrorPosition: Integer;
  90.  
  91. Begin
  92.      Val(ModeWantedAsString,ModeNumber,ErrorPosition);
  93.      If ErrorPosition = 0 Then
  94.         Begin
  95.         If (ModeNumber >-1) and (ModeNumber< 128) Then
  96.            Asm
  97.            MOV AX,ModeNumber    { Mode number is an integer }
  98.            INT $10              { Video mode set by AL }
  99.            End
  100.         Else
  101.             Begin
  102.             Writeln;
  103.             Writeln('Cannot set this video mode, video mode number');
  104.             Writeln('MUST be in the range of 0-127 ! .');
  105.             Writeln;
  106.         End;
  107.         End
  108.      Else
  109.          Begin
  110.          Writeln('Cannot set video mode - second parameter is not numeric !');
  111.          Writeln;
  112.      End;
  113. End;
  114.  
  115.  
  116. {
  117. A nice 'n' easy routine here. Pass in the video mode ya want
  118. as a short integer and the computer'll set the video mode,
  119. if it supports it that is.
  120. }
  121.  
  122. Procedure UseVideoMode(VideoModeNumber: shortint); Assembler;
  123. Asm
  124.    XOR AH,AH                    { Function 0 = Set Video Mode }
  125.    MOV AL, VideoModeNumber      { Load AL with mode wanted }
  126.    INT $10                      { Execute Video interrupt }
  127. End;
  128.  
  129.  
  130. {
  131. Convert a string to it's upper case equivalent. TheString is
  132. a string of any length less than 256 characters, and on exit
  133. the string var passed in is now entirely uppercase! Good eh?
  134. }
  135.  
  136. Procedure ConvertToUpCase(Var TheString: String);
  137. Var Count: byte;
  138. Begin
  139.      for Count := 1 to Length(TheString) do
  140.          TheString[Count] := UpCase(TheString[Count]);
  141. End;
  142.  
  143.  
  144.  
  145.  
  146. {
  147. Check what option the user has selected. (And of course, if
  148. the option is valid)
  149. }
  150.  
  151.  
  152. Procedure CheckVideoModeOptions;
  153. Var FirstParam: string;
  154.     VideoModePresetNum: byte;
  155.     ErrorPosition: integer;
  156. Begin
  157.      If ParamCount = 2 Then
  158.         Begin
  159.         FirstParam:=ParamStr(1);
  160.         ConvertToUpCase(FirstParam);
  161.  
  162.         {
  163.         I'll probably add extra parameters later.
  164.         }
  165.  
  166.         If FirstParam = 'FORCE' Then
  167.            GoIntoVideoMode(ParamStr(2))
  168.         Else
  169.             ErrorInFirstParameter;
  170.  
  171.  
  172.         End
  173.      Else
  174.          Begin
  175.          Val(ParamStr(1),VideoModePresetNum,ErrorPosition);
  176.          Case VideoModePresetNum Of
  177.               1 : UseVideoMode(3);
  178.               2 : UseVideoMode(20);
  179.               3 : UseVideoMode(84);
  180.               4 : UseVideoMode(85);
  181.          Else
  182.              Begin
  183.              Writeln;
  184.              Writeln('Can''t set mode - Preset number is unsupported !');
  185.              Writeln;
  186.          End;
  187.  
  188.          End;
  189.      End;
  190. End;
  191.  
  192.  
  193.  
  194.  
  195.  
  196. {
  197. The main program.
  198.  
  199. If no parameters are passed, then it is assumed that the user wants
  200. to see the instructions for use.
  201.  
  202. If there is 1 parameter, then it is assumed that the user wants
  203. to use a preset text mode in the range of 1 - 4 .
  204.  
  205. If there are two parameters, then the first parameter must be checked,
  206. and acted on appropriately to determine an action. Currently only 1
  207. option type exists, "FORCE". The second parameter, with FORCE,
  208. specifies the video mode to set.
  209.  
  210. }
  211.  
  212. Begin
  213.      If ParamCount = 0 Then
  214.         Usage
  215.      Else
  216.          If ParamCount >2 Then
  217.             YouArecluckingStupid
  218.          Else
  219.              CheckVideoModeOptions;
  220. End.
  221.  
  222.